package fun.xinnix.entity;

import cn.hutool.http.HttpStatus;
import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public static Result success() {
        return new Result(HttpStatus.HTTP_OK, "操作成功");
    }

    public static Result success(Object data) {
        return new Result(HttpStatus.HTTP_OK, "操作成功", data);
    }

    public static Result error() {
        return new Result(HttpStatus.HTTP_INTERNAL_ERROR, "操作失败");
    }

    public static Result error(String message) {
        return new Result(HttpStatus.HTTP_INTERNAL_ERROR, message);
    }

    public Result() {
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
